<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
{$meta}
<link type="text/css" rel="stylesheet" href="{$css_path}/global.css" />
<link type="text/css" rel="stylesheet" href="{$css_path}/style.css" />
</head><body>
<!--头部--> 
{include file="top.html"}
{include file="header.html"}
<div class="supply_demand">
  <div class="select_category">
    <ul>
      <li {if $url_type == 'supply'}class="hover"{/if}><a href="{$site_url}trade/supply" >任务</a></li>
      <li  {if $url_type == 'demand'}class="hover"{/if}><a href="{$site_url}trade/demand">需求</a></li>
    </ul>
    <div class='clear'></div>
  </div>
   <div id="trade_free_add"><a href="{$site_url}trade/add"><img src="{$images_path}/trade_free_add.jpg"/></a></div>
  <div class='clear'></div>
  <div class="supply_demand_classified"> {if count($category_list)>0}
    {foreach from=$category_list item=list}
    <dl>
      <dt>{$list.value} ： </dt>
      <dd><a href="{$site_url}trade/{$url_type}/{$list.id}" {if $selected_category==$list.id}class="selected"{/if}>全部</a></dd>
      {if !empty($list.children)}
      {foreach from=$list.children item=child}
      <dd><a href="{$site_url}trade/{$url_type}/{$child.id}" {if $selected_category==$child.id}class="selected"{/if}>{$child.value}</a></dd>
      {/foreach} 
      {/if}
    </dl>
    <div class='clear'></div>
    {/foreach} 
    {/if} </div>
  <div class="supply_demand_img"><img src="{$images_path}/supply_demand.png"/></div>
  <div class="select_display">
    <div class="high_low">
      <dl>
        <dt>排序：</dt>
        <dd><a href="javascript:void(0);" class='trade_order selected' value="time_desc">添加时间</a></dd>
        <dd><a href="javascript:void(0);" class='trade_order' value="limit_desc">到期时间</a></dd> 
        <dd><a href="javascript:void(0);" class='trade_order' value="price_desc">价格</a></dd>
        <dd><a href="javascript:void(0);" class='trade_order' value="view_desc">点击率</a></dd>
        <dd><a href="javascript:void(0);" class='trade_order' value="commont_desc">竞标数量</a></dd> 
     
      </dl>
        <div class="clear"></div>
    </div>
    <div class="supply_demand_lists">
      <div class="trade_list"> {foreach from=$trade_list item=list}
        <div class="supply_demand_detail" value="{$list.limit_time}" id="{$list.id}">
          <div class="supply_demand_picture"><img src="{$list.avatar_path}"/></div>
          <div class="supply_demand_content">
            <p ><a href="{$list.url}" id="supply_demand_title">{$list.name}</a>&nbsp;&nbsp;<span class="time_{$list.id} trade_time"></span></p>
            <p id="supply_demand_time"><a href="">{$list.username} </a>发布于{$list.add_time|date:2}&nbsp;&nbsp;浏览数量：{$list.view_count}&nbsp;&nbsp;竞标数量:{$list.comment_count}&nbsp;&nbsp;价格:{$list.account}元</p>
            <p> {$list.content|strip_tags|truncate:100} </p>
          </div>
          <div class="clear"></div>
        </div>
        {/foreach} </div>
      {$page} </div>
  </div>
  <div class="trade_list_right">
    <div class="star_office">
      <div class="star_office_top">星级办公室</div>
      <ul>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
        <li><img src="{$images_path}/per_pic.png"/>
          <p><a href="">花夕絮</a></p>
        </li>
      </ul>
      <div class="clear"></div>
    </div>
    <div class="guess_like">
      <div class="star_office_top">猜你喜欢</div>
      <ul>
        <li><a href="" class="guess_like_title">新02j4-4内装修内装修...</a><span class="guess_like_time">2012-12-08</span></li>
        <li><a href="" class="guess_like_title">新02j4-4内装修内装修...</a><span class="guess_like_time">2012-12-08</span></li>
        <li><a href="" class="guess_like_title">新02j4-4内装修内装修...</a><span class="guess_like_time">2012-12-08</span></li>
        <li><a href="" class="guess_like_title">新02j4-4内装修内装修...</a><span class="guess_like_time">2012-12-08</span></li>
        <li><a href="" class="guess_like_title">新02j4-4内装修内装修...</a><span class="guess_like_time">2012-12-08</span></li>
        <li><a href="" class="guess_like_title">新02j4-4内装修内装修...</a><span class="guess_like_time">2012-12-08</span></li>
      </ul>
    </div>
  </div>
</div>
{include file="footer.html"}
<div id="server_time" style="display:none;">{$server_time}</div>
<script type="text/javascript">
$(function(){	

	//排序
	$('.trade_order').click(function(){
		var order_arr = $(this).attr('value').split('_');
		var order_where = order_arr[1]=='desc'?'asc':'desc';
		$(this).attr('value',order_arr[0]+'_'+order_where);
		$('.trade_order').removeClass('selected');
		$(this).addClass('selected');
		var category_id = {$selected_category};
		var post_type = '{$url_type}';
		var page_num = {$page_num};
		$.ajax({
			url:'{$site_url}trade/ajax/order_post',
			type:'post',
			data:'category_id='+category_id+'&post_type='+post_type+'&order_type='+order_arr[0]+'&order_con='+order_arr[1]+'&page_num='+page_num,
			dataType:'json',
			success:function(data){
					var html = ' ';
					  $.each(data, function(i, n){
						  html = html+' <div class="supply_demand_detail" value="'+n.limit_time+'" id="'+n.id+'">';
						  html = html+' <div class="supply_demand_picture"><img src="'+n.avatar_path+'"/></div>';
						  html = html+'  <div class="supply_demand_content">';
						  html = html+'   <p><a href="'+n.url+'" id="supply_demand_title">'+n.name+'</a><span class="time_'+n.id+' trade_time"></span></p>';
						  html = html+'  <p id="supply_demand_time"><a href="">'+n.username+'</a>发布于('+n.floortime+')&nbsp;&nbsp;浏览数量：'+n.view_count+'&nbsp;&nbsp;竞标数量:'+n.comment_count+'&nbsp;&nbsp;价格:'+n.account+'元</p>';
						  html = html+'   <p> '+n.content+' </p>';
						  html = html+'  </div><div class="clear"></div></div>';
					  });
					  $('.trade_list').html(html);
				
			}
		});
	});

	//倒计时
	var serverTime = $('#server_time').text()*1000;
    var dateTime = new Date();
    var difference = dateTime.getTime() - serverTime;
     
    setInterval(function(){
      $(".supply_demand_detail").each(function(){
        var obj = $(this);
        var endTime = new Date(parseInt(obj.attr('value')) * 1000);
        var nowTime = new Date();
        var nMS=endTime.getTime() - nowTime.getTime() + difference;
		var myD=Math.floor(nMS/(1000 * 60 * 60 * 24)); 
        var myH=Math.floor(nMS/(1000*60*60)) % 24; 
        var myM=Math.floor(nMS/(1000*60)) % 60; 
        var myS=Math.floor(nMS/1000) % 60;
        if(myD>= 0){ 
            var str = myD+"天"+myH+"小时"+myM+"分"+myS+"秒"; 
        }else{ 
            var str = "已结束！";     
        } 
		var timeid = $(this).attr('id');
		$('.time_'+timeid).html(str);
      });
    }, 100);
});
</script>
</body>
</html>
